package com.game.share;

import java.io.UnsupportedEncodingException;

/**
 * private 构造函数禁止实例化,禁止继承
 * 
 * @author yedawei
 * 
 */
public class Util {
	private Util() {
	}

	private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
	private static final String EMPTY_STRING = "";

	public static byte[] stringToByte(String str) {
		try {
			return str.getBytes(Global.CHAR_SET);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return EMPTY_BYTE_ARRAY;
	}

	public static String byteToString(byte[] data) {
		try {
			return new String(data, Global.CHAR_SET);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return EMPTY_STRING;
	}

}
